package com.jl.js.core;

import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.annotations.JSStaticFunction;

import com.jl.util.HexUtil;

public class JSHexUtil extends ScriptableObject {

	public JSHexUtil() {
	}

	@Override
	public String getClassName() {
		return "HexUtil";
	}

	@JSStaticFunction
	public static String format(String str) {
		return HexUtil.format(str);
	}

	@JSStaticFunction
	public static String compact(String str) {
		return HexUtil.compact(str);
	}

	@JSStaticFunction
	public static boolean strictCheck(String str) {
		return HexUtil.strictCheck(str);
	}

	@JSStaticFunction
	public static boolean check(String str) {
		return HexUtil.strictCheck(str);
	}

	@JSStaticFunction
	public static String toHexXX(int value) {
		return HexUtil.toHexXX(value & 0xFFFFFFFFL);
	}
	
	@JSStaticFunction
	public static String toHex(int value,int len) {
		return String.format("%0" + len*2 + "X", value & 0xFFFFFFFFL);
	}
	
	@JSStaticFunction
	public static int toByte(String hex) {
		return HexUtil.parseHexToByte(hex) & 0xFF;
	}
	
	@JSStaticFunction
	public static int getHexCount(String hex) {
		return HexUtil.getHexCount(hex);
	}
	
	@JSStaticFunction
	public static String subHex(String hex,int begin,int end) {
		return HexUtil.subHex(hex,begin,end);
	}
	@JSStaticFunction
	public static boolean compare(String exp, String real) {
		return HexUtil.compare(exp, real);
	}
	

}
